package chapter9;

/**
 * Apple类，该类有一个T类型的泛型形参
 * @param <T>
 */
public class Apple<T> {
    private T info;
    public Apple() {}
    public Apple(T info) {
        this.info = info;
    }

    public T getInfo() {
        return info;
    }

    public void setInfo(T info) {
        this.info = info;
    }

    public static void main(String[] args) {
        //声明对象时，指定泛型的实际类型，如下的String和Double
        Apple<String> a1 = new Apple<>("苹果");
        Apple<Double> a2 = new Apple<>(5.62);
        System.out.println(a1.getInfo());
        System.out.println(a2.getInfo());
    }
}
